Skip to content

Migrate from rolldown to tsdown#4025

Merged
nstepien merged 1 commit intomainfrom
tsdown
Apr 2, 2026
Merged

Migrate from rolldown to tsdown#4025
nstepien merged 1 commit intomainfrom
tsdown

Conversation

@nstepien
Copy link
Copy Markdown
Collaborator

@nstepien nstepien commented Apr 1, 2026

  • rolldown dropped support for CSS, unclear when it'll be restored, if ever
  • vite's library mode does not support outputting declaration files
  • tsdown, built on top of rolldown, is the ideal lib bundling tool for rdg

https://tsdown.dev/
https://github.com/rolldown/tsdown

before

<DIR>/styles.css      asset │ size:   9.78 kB
<DIR>/styles.css.map  asset │ size:  12.75 kB
<DIR>/index.js.map    asset │ size: 216.46 kB
<DIR>/index.d.ts      chunk │ size:  23.08 kB
<DIR>/index.js        chunk │ size:  99.18 kB

✔ rolldown v1.0.0-rc.5 Finished in 481.46 ms

after

ℹ tsdown v0.21.7 powered by rolldown v1.0.0-rc.12
ℹ config file: D:\repos\react-data-grid\.claude\worktrees\vitelib\tsdown.config.ts 
ℹ entry: src\index.ts
ℹ tsconfig: tsconfig.json
ℹ Build start
ℹ Cleaning 5 files
ℹ lib\index.js       98.39 kB │ gzip: 21.95 kB
ℹ lib\index.js.map  217.24 kB │ gzip: 53.86 kB
ℹ lib\styles.css      8.22 kB │ gzip:  2.12 kB
ℹ lib\index.d.ts     23.10 kB │ gzip:  5.14 kB
ℹ 4 files, total: 346.95 kB
✔ Build complete in 187ms

build output changes

We've lost the sourcemaps for CSS files, not a major concern.

In the JS, besides empty lines being removed, some const values are inlined:

image image

In the declaration file, the name of namespace imports changed, that's it:

image

The CSS file is processed by lightningcss, so it has more changes, but nothing major, some highlights:

image image image image

@nstepien nstepien self-assigned this Apr 1, 2026
@nstepien nstepien marked this pull request as ready for review April 1, 2026 22:49
@nstepien nstepien requested a review from amanmahajan7 as a code owner April 1, 2026 22:49
Copy link
Copy Markdown
Collaborator

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. What is the default build target? Does it use baseline-widely-available?

cleanDir: true
},
outDir: 'lib',
platform: 'neutral',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be platform: 'browser'?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, we want to support SSR as well, so the lib should be compatible with node.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI there's no build output difference at the moment if we set platform: 'browser'

@nstepien
Copy link
Copy Markdown
Collaborator Author

nstepien commented Apr 2, 2026

What is the default build target? Does it use baseline-widely-available?

https://tsdown.dev/options/target

If you don't specify a target and your package.json doesn't have an engines.node field, tsdown will behave as if target: false was set, preserving all modern syntax.

No syntax downgrade unless we set target or engines.node.
Which is probably fine, our rolldown config wasn't transpiling code either.
We can revisit if it's ever needed.

@nstepien nstepien requested a review from amanmahajan7 April 2, 2026 14:15
@nstepien nstepien merged commit 37a841f into main Apr 2, 2026
2 checks passed
@nstepien nstepien deleted the tsdown branch April 2, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants